Getting Started with IBM DB2 on Linux Part II: Installation With DB2 Setup Wizard

Aug. 3, 2021, 3 p.m.

This is the second article in a series of articles on getting started with IBM's Db2 Database, a Relational Database Management System (RDBMS) that is part of a collection of data management and analysis software. The first article of the series -- Getting Started with IBM DB2 on Linux Part I: Background and Installation Preparation, discussed downloading the installation image, preparation for installation, and the available installation methods. The current article describes one of the installation methods -- the Db2 Setup GUI wizard. This method can be used on a Linux system with a fully configured desktop environment so that the wizard GUI is displayed directly on the target computer, or on a system without a desktop environment but with X Window System client software, so that the GUI is displayed on and inputs received from a remote computer. Both scenarios are discussed.

Introduction

The wizard installs the the Db2 Database software, by default to /opt/ibm/db2/V11.5, which can be overriden in the wizard. This populating of the /opt/ibm/db2/V11.5 is also done by the other installation methods, but the wizard performs other tasks to simplify getting started with Db2 Database. It:

  • creates one RDBMS instance, creating its home directory
  • creates an instance owning OS user for managing the created instance
  • creates an instance fenced OS user under which processes created by certain features of the Db2 Database instance run
  • configures Db2 Database network communication so remote clients can connect to the created instance

The concepts of an instance, instance owning user, and instance owning fenced user are central to the operation of Db2 Database and are discussed in Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts But to briefly describe them here, an instance is one containment level within the hierarchical containment levels of Db2 Database. The instance level containment is a separate self-contained database environment consisting of RDBMS configuration, RDBMS program execution, and RDBMS managed data. Db2 Database supports the installation of multiple copies of the software on a single computer. For each installation of the software, multiple instances that are associated with the specific copy of the database software are supported. Within the instance can be multiple databases and within the databases lower level database objects, such as tables, indexes, and views, etc.

Section Installing on Machine with a Desktop Environment Using Wizard, below, the process of installing Db2 Database in an Ubuntu 18.04 VM with a fully configured desktop environment is described. This configuration includes the underlying setup of the X Window System -- both client and server, so we can run the DB2 Setup wizard and the wizard's window will appear as any other application's window running on the machine. In Section Installing on Machine without a Desktop Environment Using Wizard, further below, the process of installing Db2 Database on the Ubuntu 18.04 VM without a desktop environment, also using the wizard is described. However, in this case, while the wizard is executed directly on the VM through an SSH connection, the wizard's GUI window will be displayed on the computer from which we have established the SSH connection to the VM. Here, the installation is performed on a VM running on a local computer (the VM host) through an SSH connection from the local computer to the VM guest (remote computer). While in the previous scenario both X Window System server and client software are available, in this case at least X Window System client software needs to be installed.

Installing Directly on a Computer with a Desktop Environment Using Db2 Setup Wizard

The Db2 Setup wizard executable is in the same directory as the prerequisite checking tool mentioned in the last part of this article series. We run it using the following steps directly on the target computer using its desktop environment.

  1. It must be run as root, so if not already root use the following to switch user to root.
    db2user@u1804-lab:~$ su - root
  2. Change directory to the directory which contained the prerequisite checking tool as seen in the previous article of the series.
    root@u1804-lab:~# cd /home/db2user/software/ibm_db2
    Remember that /home/db2user is the home folder created to perform the installation. Adjust the above for your case.
  3. Start the wizard with:
    root@u1804-lab:/home/db2user/software/ibm_db2# ./db2setup

Upon executing the wizard on a system with a fully configured desktop environment, such as the Kubuntu 18.04 VM, the window shown in the first image of the following set of screenshots is be displayed. The subsequent images show the following screens of the installer. Click on any of the thumbnails for a slideshow of each screen of the installer. The most notable screens of the wizard are described below.

  • Image 2:
    After clicking New Install on the initial screen of the wizard, the next screen allows selection of the Db2 Database product to install. The main RDBMS product, the RDBMS server, is preselected. In this case the Db2 version is 11.5.5.0 and the selected item is "DB2 Version 11.5.5.0 Server Editions".
  • Image 3 and 5:
    After selecting the server product, the next step is to choose between a typical installation or a customized installation. Clicking View Features while the Typical installation button is active will show the features to be installed in a typical installation (Image 4). Clicking the Custom installation button and selecting Next will open a dialog allowing selection of features to be installed (Image 6).
  • Image 10:
    The DB2 Setup screen shown in Image 10 prompts users whether the installation will create a single partition instance or a multiple partition instance. A partitioned instance is one where the tables in the created instance's databases will be distributed among multiple computers, or in general RDBMS terminology, among multiple nodes. A single partition instance is chosen for this demonstration. (For a description of instances, how they relate to multiple installations of DB2, and the containment hierarchy available in Db2 see Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts.)
  • Image 11:
    The DB2 Setup screen shown in Image 11 relates to the instance owning user. Each Db2 instance must be owned by an OS user with the same username as the instance name. The instance owning user, also known as the instance owner, has administrative rights for managing the instance. The installer can create such a user for this purpose using the low level useradd Linux utility. The home directory of the instance owner will contain the configuration files of the instance as well as all the files that actually hold the data of the instances databases. (For a description of instances, how they relate to instance owning users, and the important directories of Db2 see Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts.)
  • Image 12:
    The DB2 Setup screen shown in Image 12 relates to the fenced instance owning user. Certain processes created by the Db2 RDBMS instance will run as this user. (For a description of instances owning users and how they relate to instances see Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts.)
  • Image 13:
    The DB2 Setup screen image shown in Image 13 configures network communication from remote clients to the instance created by the installer.
  • Image 17:
    The DB2 Setup main window screen depicted in Image 17 shows that the installer can install Db2 and save the configuration used for the installation in a response file, or simply create the response file without performing the installation. The response file is one of the non-GUI installation methods mentioned in the first article on this series. The response file created by the wizard can be used to install Db2 on other computers with an identical configuration -- useful for installing Db2 on other computers to create a partitioned Db2 environment. Other methods of generating a response file are available for any possible configuration, including partitioned environments and are discussed in Getting Started with IBM DB2 on Linux Part III: Manual Installation.
    • Installing IBM Db2 Database Directly on a Computer with a Desktop Environment Using the Db2 Setup Installation Wizard
      The installation wizard Uses the X Window System to display the installer's graphical display on the on the installation target if it has an desktop environment (as in this section) or on a local computer which is remotely connected to the installation target (as in the next section).
      Click on any of the thumbnails to view a slideshow of the images.

      All screens and options of the GUI wizard executed on the remote computer but displayed on the local computer is exactly the same as in the previous installation on a computer with a desktop environment.

Installing on a Remote Computer Without a Desktop Environment Using Db2 Setup Wizard

The previous section described the process of installing Db2 Database using the wizard directly on a computer with a fully configured desktop environment -- in this case the Kubuntu 18.04 implementation of KDE's Plasma. This section describes the installation process using the DB2 Setup wizard on a target computer which does not have a desktop environment by remotely connecting to it through an SSH connection but displaying and interacting with the wizard's GUI on the local computer. This method relies on the X Window System's power as a client/server network application, where applications with GUI's are X clients which display their windows on a computer with an X server. Even when programs are executed and displayed on the same computer as in the previous section, applications use the X client software to connect to and display their output and receive interaction via mouse and keyboard using the X server running on the same computer. Although the X window system is capable of this remote capability on its own, an SSH connection is used to forward the display to the local computer in order to simplify the X communication configuration as X forwarding is built into SSH. The process is described below.

  1. Ensure the remote computer, the target of the installation has a Fully Qualified Domain Name (FQDN) configured in its hosts file, and if it is an actual server on the internet that it is also accessible through the DNS system. For the purposes of this article the VM that serves as the remote host for the example is configured as u1804-lab.localdomain in its hosts file. It is accessible on the local network configured by VirtualBox as 192.168.56.102. The local computer is on the same network at 192.168.56.1. The FQDN of the remote host can be verified with the command shown below:
    db2user@u1804-lab:~$ hostname -f
    u1804-lab.localdomain
  2. Allow the remote X client to display on the local computer through the local X server.
    20:24:54 θ68° [brook@G5-openSUSE:~] $ xhost + u1804-lab.localdomain
    xhost:  bad hostname "u1804-lab.localdomain"
    . The above command without specifying a specific host will allow any remote host to display windows on the local computer. By specifying a specific host, only the indicated remote host, u1804-lab.localdomain will be allowed to display windows on the local computer, reducing security risks.
  3. Connect to remote machine, the target of the Db2 installation.
    20:27:38 θ67° [brook@G5-openSUSE:~] $ ssh -X -i /home/brook/DataEXT4/ssh/id_ed25519_db2user db2user@192.168.56.102
  4. The DISPLAY environment variable on the remote host is configured by the ssh client through the use of the - X option when invoking ssh.
    db2user@u1804-lab:~$ echo $DISPLAY
    localhost:10.0
    If not using X forwarding through SSH and using X's native forwarding the DISPLAY environment variable would have to be configured manually.
  5. At this point any GUI application executed in the terminal with the SSH connection invoked with the -X option will display the GUI window on the local computer even though it is executed in the remote computer. So, now the DB2 Setup wizard can be started on the remote machine and have the window displayed on the local computer. The setup wizard must be executed as the root user with the root user's profile. However doing so at this point will not work because the SSH connection is for the user for which the SSH connection and X forwarding was established, in this case db2user. To allow the setup wizard to be executed as root and the wizard's GUI to be forwarded with the SSH connection established for the regular user, continue with the following steps.
  6. Determine the X Window authorization cookie for the current SSH forwarded X session.
    db2user@u1804-lab:~$ xauth list $DISPLAY
    u1804-lab/unix:10  MIT-MAGIC-COOKIE-1  9a3e54b3607a593b75cd14b27f808742
    This shows that for the forwarded session the DISPLAY environment variable is u1804-lab/unix:10 and the authorization cookie for the current session and user that initiated the SSH connection is the string following MIT-MAGIC-COOKIE-1. The magic cookie is also stored in binary form in the user's home directory in the file ~/.Xauthority. To allow the X window created when a program is executed as root to be forwarded through SSH, the same magic cookie must be placed in root's .Xauthority with the xauth command.
  7. Switch to root.
    db2user@u1804-lab:~$ su - root
    Password: 
    root@u1804-lab:~#
  8. Use touch to create the file /root/.Xauthority in case it does not already exist.
    root@u1804-lab:~# touch /root/.Xauthority
  9. Add the magic cookie to root's .Xauthority.
    root@u1804-lab:~# xauth add u1804-lab/unix:10  MIT-MAGIC-COOKIE-1  9a3e54b3607a593b75cd14b27f808742
    The argument to xauth add is the same as the output to xauth list $DISPLAY in Step 5, above. Now the DB2 Setup wizard can be started as root and the wizard's window will be forwarded to the local computer's X server through the SSH connection created by the regular user.
  10. Change directory to the location of the wizard executable.
    root@u1804-lab:~# cd /home/db2user/software/ibm-db2
  11. Start the wizard.
    root@u1804-lab:~#  ./db2setup

Upon starting the installer wizard on the remote computer through the SSH connection, the graphical output is displayed on the local computer; the wizard's splash screen is displayed followed by a license notice, then the first screen of the wizard, as depicted by the first image in the following set of screenshots.

Installing IBM Db2 Database on a Computer without a Desktop Environment Using the Db2 Setup Installation Wizard through a Remote Connection
The installation wizard Uses the X Window System to display the installer's graphical display on the on the installation target if it has an desktop environment (as in the previous section) or on a local computer which is remotely connected to the installation target (as in this section). The desktop environment depicted in these screenshots is the local computer. The Db2 Setup window is generated on the remote computer and displayed on the local computer.
Click on any of the thumbnails to view a slideshow of the images.

Validating Installation

Each of the installations of Db2 includes a tool to validate the installation and the instance of the RDBMS created by the installer in each installation directory. For the first installation, with the wizard directly on the machine with the desktop environment, the process for which was detailed in the section Installing Directly on a Computer with a Desktop Environment Using Db2 Setup Wizard, the installation directory is at /opt/ibm/db2/V11.5. And for the second installation, where the wizard was invoked remotely through an SSH connection and the wizard's window was forwarded to the local computer through the connection, detailed in the section Installing on a Remote Computer Without a Desktop Environment Using Db2 Setup Wizard, the installation is at /opt/ibm/db2/V11.5_01.

The validation tool for each installation is located in the bin subdirectory of each installation directory. The tool must be executed as the instance owning user of the instance created with each installation, db2inst1 and db2inst2, for the first and second installations, respectively. (As we will see in Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts any user added to the primary user groups of the instance owning users can also run these tools). To validate the fist installation and the instance created by the first installation:

  1. First switch user to the instance owning user of the created instance.
    root@u1804-lab:/home/db2user/software/ibm-db2 # su - db2inst1
    The creation of the instance and the instance owning user during the first use of Db2 Setup was shown in Image 11 of the first set of screenshots.
  2. Change directory to the directory that contains the validation tool for the installed copy of DB2.
    $ cd /opt/ibm/db2/V11.5/bin
    Note that the login shell assigned to users created by the wizard is the Bourne Shell, a capability provided by dash on Ubuntu, due to the default configuration of the useradd utility. This is the reason for the simple $ shell prompt. When creating an instance and the necessary instance users in Getting Started with IBM DB2 on Linux Part III: Manual Installation, Bash is assigned as their login shell.
  3. Run the validation tool.
    $ ./db2val

The output of the tool is shown below for a successful installation and instance creation.

DBI1379I  The db2val command is running. This can take several minutes.

DBI1335I  Installation file validation for the DB2 copy installed at
      /opt/ibm/db2/V11.5 was successful.

DBI1339I  The instance validation for the instance db2inst1 was
      successful.

DBI1343I  The db2val command completed successfully. For details, see
      the log file /tmp/db2val-201230_201241.log.

The second installation can be validated similarly, by first switching to db2inst2 and running the tool as shown in the following listing.

root@u1804-lab:/home/db2user/software/ibm-db2# su db2inst2
$ cd /opt/ibm/db2/V11.5_01/bin
$ ./db2val
DBI1379I  The db2val command is running. This can take several minutes.

DBI1335I  Installation file validation for the DB2 copy installed at
      /opt/ibm/db2/V11.5_01 was successful.

DBI1343I  The db2val command completed successfully. For details, see
      the log file /tmp/db2val-210111_191439.log.


$

Installation Results

The DB2 Setup wizard installs a copy of DB2, by default in /opt/ibm/db2 in a directory named after the version of DB2 being installed, in this case V11.5, such that the full path of the first installed copy of DB2 is at /opt/ibm/db2/V11.5. Subsequent installations of the same version of will have an underscore and a monotonically increasing two digit number appended beginning with _01, as was the case for the second installation. (For a description of installation fo multiple copies of Db2 and its containment hierarchy, see Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts. Information on the installation can be viewed with a tool included with the installation, available to all users as it is located in /usr/local/bin, a path that is set in the environment variable PATH of all users by default in Ubuntu based systems.

db2user@u1804-lab:~$ db2ls

Install Path                       Level   Fix Pack   Special Install Number   Install Date                  Installer UID 
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V11.5               11.5.5.0        0                            Tue Dec 29 18:36:57 2020 EST             0 
/opt/ibm/db2/V11.5_01            11.5.5.0        0                            Sun Jan 10 20:11:01 2021 EST             0 
db2user@u1804-lab:~$

This population of this path is performed by the other installation methods as well, but the wizard also performs some configuration that simplifies getting started with Db2 Database. It optionally creates one instance of the RDBMS to be associated with the installed copy of the Db2 Database server software, which for the first created instance is named db2inst1. It creates an instance owing user and instance fenced user, db2inst1 and db2fenc1, respectively. The instance home directory is the instance owner's directory, /home/db2inst1. Other important instance specific directories exist in this instance home and are discussed in Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts. Paths for each instance user are set by sourcing a script within one of these instance home directories, and is also discussed in Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts.

Next Steps

The installation of Db2 Database using the wizard simplifies the installation and subsequent configuration of Db2. It creates one instance and the necessary users, configuring even network communication to the instance, allowing users to immediately start using the instance. However, it can only create one instance. If multiple instances are required to be associated with an installed copy, they must be created manually or created using a response file installation. Creating instances and manual installation by extracting the payload file, using the db2_install command, and using the response file are discussed in the next part of this article series, Getting Started with IBM DB2 on Linux Part III: Manual Installation .

An additional issue is that before interacting with the instance, the appropriate environment variables must be set. The environment variables and the tools provided by Db2 to automate their setting, as well as the other fundamental concepts of Db2 Database is the subject of Getting Started with IBM DB2 on Linux Part IV: Fundamental Concepts

References